#! /usr/bin/python

import math

l=[]
l.append(2)

for i in range(0, 99):
    if i%3 == 0 or i%3 == 2: a=1
    else: a = (int(i/3) + 1)*2
    l.append(a)


numerator = l.pop()
denominator = l.pop()*numerator+1

for i in range(0, 98):
    a = l.pop()
    t = numerator
    numerator = denominator
    denominator = a*denominator+t

sum1 = 0
while(denominator):
     sum1 = sum1 + denominator%10
     denominator /=10
print sum1
